﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PHPDecoder
{
    class PhpAutomat
    {
        public SuffixTrie tree = null;

        public PhpAutomat()
        {
            tree = new SuffixTrie();
            AddKeywords();
            tree.MakeFallFunction();
        }

        private void AddKeywords()
        {
            tree.AddString("<?", PHPKEYWORDS.PHPSTART);
            tree.AddString("public", PHPKEYWORDS.PUBLICMODIFIER);
            tree.AddString("private", PHPKEYWORDS.PRIVATEMODIFIER);
            tree.AddString("static", PHPKEYWORDS.STATICMODIFIER);
            tree.AddString("protected", PHPKEYWORDS.PROTECTEDMODIFIER);
            tree.AddString("abstract", PHPKEYWORDS.ABSTRACTMODIFIER);
            tree.AddString("function", PHPKEYWORDS.METHOD);
            tree.AddString("$", PHPKEYWORDS.VARIABLE);
            tree.AddString("global", PHPKEYWORDS.GLOBAL);
            tree.AddString("try", PHPKEYWORDS.TRY);
            tree.AddString("throw", PHPKEYWORDS.THROW);
            tree.AddString("if", PHPKEYWORDS.IF);
            tree.AddString("while", PHPKEYWORDS.WHILE);
            tree.AddString("do", PHPKEYWORDS.DO);
            tree.AddString("for", PHPKEYWORDS.FOR);
            tree.AddString("foreach", PHPKEYWORDS.FOREACH);
            tree.AddString("switch", PHPKEYWORDS.SWITCH);
            tree.AddString("?>", PHPKEYWORDS.PHPEND);
            tree.AddString("interface", PHPKEYWORDS.INTERFACE);
            tree.AddString("class", PHPKEYWORDS.CLASS);
            tree.AddString("return", PHPKEYWORDS.RETURN);
            tree.AddString("echo", PHPKEYWORDS.ECHO);
            //tree.AddString(@"//", PHPKEYWORDS.COMMENTS_1);
            //tree.AddString(@"/*", PHPKEYWORDS.COMMENTS_2);
            tree.AddString(@"case", PHPKEYWORDS.CASE);
            tree.AddString(@"break", PHPKEYWORDS.BREAK);
            tree.AddString(@"default", PHPKEYWORDS.DEFAULT);
            tree.AddString(@"include", PHPKEYWORDS.INCLUDE);
            tree.AddString(@"include_once", PHPKEYWORDS.INCLUDE_ONCE);
            tree.AddString(@"require", PHPKEYWORDS.REQUIRE);
            tree.AddString(@"require_once", PHPKEYWORDS.REQUIRE_ONCE);
            tree.AddString(@"var", PHPKEYWORDS.VAR);
            tree.AddString(@"else", PHPKEYWORDS.ELSE);
            tree.AddString(@"elseif", PHPKEYWORDS.ELSEIF);
            tree.AddString(@"exit", PHPKEYWORDS.NOP);
            tree.AddString(@"continue", PHPKEYWORDS.NOP);
        }
    }
}
